package light.head.model.inv;

import java.io.Serializable;
import java.util.Date;
import java.util.List;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
import javax.persistence.Transient;

import org.hibernate.annotations.Formula;
/**
 * 商品信息
 * @author yuleidian
 *
 */
@Entity
@Table
public class InvCommodityInfo implements Serializable{
	private static final long serialVersionUID = -9152058196553762118L;
	private Integer code;					// 流水号
	private String name;					// 名称
	private Integer pc;						// 父节点编号
	private Integer oc;						// 机构编号
	private Integer cu;						// 创建人
	private Date ct;						// 创建时间
	private Boolean isCommodity;			// 是否商品
	private Boolean deleted = false;		// 是否删除
	//Formula字段
	private String pn;						// 父节点名称
	//临时字段
	private List<InvCommodityInfo> sonList;	// 该信息下的子信息列表
	private InvCommodityItem cItem;			// 商品信息详情
	
	@Id
	@GeneratedValue(strategy = GenerationType.IDENTITY)
	@Column
	public Integer getCode() {
		return code;
	}
	@Column
	public String getName() {
		return name;
	}
	@Column
	public Integer getOc() {
		return oc;
	}
	@Column
	public Integer getPc() {
		return pc;
	}
	
	@Column(updatable = false, nullable = false)
	public Integer getCu() {
		return cu;
	}
	@Temporal(TemporalType.TIMESTAMP)
	@Column(updatable = false, nullable = false)
	public Date getCt() {
		return ct;
	}
	@Column
	public Boolean getIsCommodity() {
		return isCommodity;
	}
	@Column
	public Boolean getDeleted() {
		return deleted;
	}
	//Formula字段
	@Formula("(SELECT ci.name FROM InvCommodityInfo ci WHERE ci.code = pc)")
	public String getPn() {
		return pn;
	}
	//临时字段
	@Transient
	public List<InvCommodityInfo> getSonList() {
		return sonList;
	}
	@Transient
	public InvCommodityItem getcItem() {
		return cItem;
	}
	
	
	public void setCode(Integer code) {
		this.code = code;
	}
	public void setName(String name) {
		this.name = name;
	}
	public void setPc(Integer pc) {
		this.pc = pc;
	}
	public void setCu(Integer cu) {
		this.cu = cu;
	}
	public void setCt(Date ct) {
		this.ct = ct;
	}
	public void setDeleted(Boolean deleted) {
		this.deleted = deleted;
	}
	public void setOc(Integer oc) {
		this.oc = oc;
	}
	public void setSonList(List<InvCommodityInfo> sonList) {
		this.sonList = sonList;
	}
	public void setcItem(InvCommodityItem cItem) {
		this.cItem = cItem;
	}
	public void setPn(String pn) {
		this.pn = pn;
	}
	public void setIsCommodity(Boolean isCommodity) {
		this.isCommodity = isCommodity;
	}
}
